﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteUser.Master" AutoEventWireup="true" CodeBehind="SearchForUser.aspx.cs" Inherits="WebPresentation.SearchForUser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">

        .style1
        {
            width: 456px;
        }
        .style4
        {
            width: 456px;
            height: 26px;
        }
        .style5
        {
            height: 26px;
        }
        </style>
        <script type="text/javascript" src="Scripts/jquery.ui.datepicker.js"></script>
    <script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.8.20.custom.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $("#MainContent_txtdate").datepicker({ dateFormat: 'dd-mm-yy' });
            $("#MainContent_txtdate1").datepicker({ dateFormat: 'dd-mm-yy' });
            $("#MainContent_txtdate2").datepicker({ dateFormat: 'dd-mm-yy' });
            $("#MainContent_txtDateEdit").datepicker({ dateFormat: 'dd-mm-yy' });

            $('.hiddenField, #MainContent_dtgdoc th:nth-child(1)').hide();
            $("#MainContent_LinkButtonsearch").click(function () {
                $("#advsearch").toggle();
                return false;
            });
            $("#MainContent_LinkButtonadd").click(function () {
                $("#add").toggle();
                $("#edit").hide();
                $("#delete").hide();
                return false;
            });
            $("#MainContent_LinkButtonedit").click(function () {
                $("#edit").toggle();
                $("#add").hide();
                $("#delete").hide();
                return false;
            });

            $('#MainContent_dtgdoc tr').each(function () {
                if (!$(this).find("td").eq(4).find("span input").is(":checked")) {
                    $(this).find("td").eq(6).text("Not set");
                }
                var storePath = $(this).find("td.storePath").text();
                $(this).find("td.storePath").html("<a href=\"" + storePath + "\">Download</a>");
            });
        });
	      
    </script>  
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div align="center">
        <asp:Label ID="Label10" runat="server" Width="100%" ForeColor="Red" 
        Font-Bold="True"></asp:Label>
    </div>
    <br />
    <div>
        <table style="width: 100%;">
            <tr>
                <td align="center" width="25%">
                &nbsp;
                </td>
                <td align="center" width="25%">
                    <asp:LinkButton ID="LinkButtonBack" runat="server" 
                    PostBackUrl="~/Document.aspx" onclick="LinkButtonBack_Click">Back to document page</asp:LinkButton>
                &nbsp;
                </td>
                <td align="center" width="25%">
                
                &nbsp;</td>
                <td align="center" width="25%">
                &nbsp;
                </td>
            </tr>
        </table>
    </div>
    <div id="add" style="display:none">
        <fieldset>
            <legend>Document Information:</legend>
            <table style="width: 100%;">
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label1" runat="server" Text="Document No:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtdocno" runat="server" Width="170px" 
                    style="margin-left: 1px"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label2" runat="server" Text="Type:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="ddldoctype" runat="server" Width="150px" 
                    style="margin-left: 2px" DataSourceID="DocTypeObjectSource" 
                    DataTextField="dtName" DataValueField="dtID">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="DocTypeObjectSource" runat="server" 
                    DeleteMethod="DeleteDocType" InsertMethod="AddNewDocType" 
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDocTypes" 
                    TypeName="BusinessLogic.DocTypeBO" UpdateMethod="UpdateDocTypes">
                            <DeleteParameters>
                                <asp:Parameter Name="dtID" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="dtName" Type="String" />
                                <asp:Parameter Name="dtCode" Type="String" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="dtName" Type="String" />
                                <asp:Parameter Name="dtCode" Type="String" />
                                <asp:Parameter Name="dtID" Type="Int32" />
                            </UpdateParameters>
                        </asp:ObjectDataSource>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style4">
                        <asp:Label ID="Label3" runat="server" Text="Sender:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left" class="style5">
                        <asp:DropDownList ID="ddlsender" runat="server" Width="150px" 
                    style="margin-left: 2px" DataSourceID="DepartmentObjectSource" 
                    DataTextField="depName" DataValueField="depID">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="DepartmentObjectSource" runat="server" 
                    DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" 
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDepartments" 
                    TypeName="BusinessLogic.DepartmentBO" UpdateMethod="UpdateDepartment">
                            <DeleteParameters>
                                <asp:Parameter Name="depID" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="depName" Type="String" />
                                <asp:Parameter Name="depCode" Type="String" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="depName" Type="String" />
                                <asp:Parameter Name="depCode" Type="String" />
                                <asp:Parameter Name="depID" Type="Int32" />
                            </UpdateParameters>
                        </asp:ObjectDataSource>
                    </td>
                    <td class="style5">
                    </td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label4" runat="server" Text="Received Date:" Width="140px" 
                    style="text-align:left" Font-Bold="True" ClientIDMode="Inherit"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtdate" runat="server"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label7" runat="server" Text="Shortened Details:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtdetails" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label8" runat="server" Text="Store Path:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:FileUpload ID="fileUpload" runat="server" />
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                &nbsp;</td>
                    <td align="left">
                &nbsp;</td>
                    <td>
                &nbsp;</td>
                </tr>
            </table>
            <div align="center" >
                <asp:ImageButton ID="ImageButtonadd" runat="server" 
            ImageUrl="~/Images/addbutton.png" onclick="ImageButtonadd_Click" />
            </div>
        </fieldset>
    </div>
    <br />
    <div id="edit" style="display:none">
        <fieldset>
            <legend>Document Information:</legend>
            <table style="width: 100%;">
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label15" runat="server" Text="Document No:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtDocNoEdit" runat="server" Width="170px" 
                    style="margin-left: 1px"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label18" runat="server" Text="Type:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:DropDownList ID="DropDownType" runat="server" Width="150px" 
                    style="margin-left: 2px" DataSourceID="DocTypeObjectSource" 
                    DataTextField="dtName" DataValueField="dtID">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                    DeleteMethod="DeleteDocType" InsertMethod="AddNewDocType" 
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDocTypes" 
                    TypeName="BusinessLogic.DocTypeBO" UpdateMethod="UpdateDocTypes">
                            <DeleteParameters>
                                <asp:Parameter Name="dtID" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="dtName" Type="String" />
                                <asp:Parameter Name="dtCode" Type="String" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="dtName" Type="String" />
                                <asp:Parameter Name="dtCode" Type="String" />
                                <asp:Parameter Name="dtID" Type="Int32" />
                            </UpdateParameters>
                        </asp:ObjectDataSource>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style4">
                        <asp:Label ID="Label19" runat="server" Text="Sender:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left" class="style5">
                        <asp:DropDownList ID="DropDownSender" runat="server" Width="150px" 
                    style="margin-left: 2px" DataSourceID="DepartmentObjectSource" 
                    DataTextField="depName" DataValueField="depID">
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                    DeleteMethod="DeleteDepartment" InsertMethod="InsertDepartment" 
                    OldValuesParameterFormatString="original_{0}" SelectMethod="GetAllDepartments" 
                    TypeName="BusinessLogic.DepartmentBO" UpdateMethod="UpdateDepartment">
                            <DeleteParameters>
                                <asp:Parameter Name="depID" Type="Int32" />
                            </DeleteParameters>
                            <InsertParameters>
                                <asp:Parameter Name="depName" Type="String" />
                                <asp:Parameter Name="depCode" Type="String" />
                            </InsertParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="depName" Type="String" />
                                <asp:Parameter Name="depCode" Type="String" />
                                <asp:Parameter Name="depID" Type="Int32" />
                            </UpdateParameters>
                        </asp:ObjectDataSource>
                    </td>
                    <td class="style5">
                    </td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label20" runat="server" Text="Received Date:" Width="140px" 
                    style="text-align:left" Font-Bold="True" ClientIDMode="Inherit"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtDateEdit" runat="server"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label23" runat="server" Text="Shortened Details:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:TextBox ID="txtShortenedDetail" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label24" runat="server" Text="Store Path:" Width="140px" 
                    style="text-align:left" Font-Bold="True"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:FileUpload ID="fileUpload1" runat="server" />
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
                <tr>
                    <td align="right" class="style1">
                        <asp:Label ID="Label33" runat="server" Font-Bold="True" Text="Status" 
                    Width="140px"></asp:Label>
                    </td>
                    <td align="left">
                        <asp:CheckBox ID="cbStatus" runat="server" />
                    </td>
                    <td>
                &nbsp;</td>
                </tr>
            </table>
            <div align="center" >
                <asp:ImageButton ID="ImageButtonedit" runat="server" 
            ImageUrl="~/Images/editbutton.png" onclick="ImageButtonedit_Click" />
            </div>
        </fieldset>
    </div>
    <br />
    <div id="advsearch" style="display: none">
        &nbsp;</div>
    <fieldset>
        <legend>Details:</legend>
        <div>
            <asp:GridView ID="dtgdoc" runat="server" Width="100%" BackColor="White" 
            BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" 
            ForeColor="Black" GridLines="Vertical" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" 
            DataSourceID="DocumentObjectSource" 
            onselectedindexchanged="dtgdoc_SelectedIndexChanged" DataKeyNames="docID">
                <AlternatingRowStyle BackColor="#CCCCCC" />
                <Columns>
                    <asp:BoundField DataField="docID" HeaderText="docID" InsertVisible="False" 
                    ReadOnly="True" SortExpression="docID" >
                    <ItemStyle CssClass="hiddenField" />
                    </asp:BoundField>
                    <asp:BoundField DataField="DocCode" HeaderText="DocCode" ReadOnly="True" 
                    SortExpression="DocCode" />
                    <asp:BoundField DataField="Sender" HeaderText="Sender" 
                    SortExpression="Sender" />
                    <asp:BoundField DataField="shortenedDetail" HeaderText="shortenedDetail" 
                    SortExpression="shortenedDetail" />
                    <asp:BoundField DataField="dateOfReceipt" HeaderText="dateOfReceipt" 
                    SortExpression="dateOfReceipt" />
                    <asp:BoundField DataField="storePath" HeaderText="storePath" 
                    SortExpression="storePath" >
                    <ItemStyle CssClass="storePath" />
                    </asp:BoundField>
                </Columns>
                <FooterStyle BackColor="#CCCCCC" />
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#808080" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#383838" />
            </asp:GridView>
            <asp:ObjectDataSource ID="DocumentObjectSource" runat="server" 
            DeleteMethod="Delete"
            SelectMethod="GetByDocCode" TypeName="BusinessLogic.DocumentBO" 
            UpdateMethod="Update" InsertMethod="AddNewDocument" 
                OldValuesParameterFormatString="original_{0}">
                <DeleteParameters>
                    <asp:Parameter Name="docID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="docNumber" Type="Int32" />
                    <asp:Parameter Name="dtID" Type="Int32" />
                    <asp:Parameter Name="docSender" Type="Int32" />
                    <asp:Parameter Name="dateOfReceipt" Type="DateTime" />
                    <asp:Parameter Name="adoptedBy" Type="Int32" />
                    <asp:Parameter Name="inOut" Type="Boolean" />
                    <asp:Parameter Name="shortenedDetail" Type="String" />
                    <asp:Parameter Name="storePath" Type="String" />
                </InsertParameters>
                <SelectParameters>
                    <asp:QueryStringParameter Name="docCode" QueryStringField="docCode" 
                    Type="String" />
                    <asp:SessionParameter Name="depCode" SessionField="UserDepartment" 
                        Type="String" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="docNumber" Type="Int32" />
                    <asp:Parameter Name="dtID" Type="Int32" />
                    <asp:Parameter Name="docSender" Type="Int32" />
                    <asp:Parameter Name="dateOfReceipt" Type="DateTime" />
                    <asp:Parameter Name="shortenedDetail" Type="String" />
                    <asp:Parameter Name="storePath" Type="String" />
                    <asp:Parameter Name="status" Type="Boolean" />
                    <asp:Parameter Name="docID" Type="Int32" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        </div>
    </fieldset> 
</asp:Content>
